#ifndef __TOYM__NET__POLLERS__POLLER_H__
#define __TOYM__NET__POLLERS__POLLER_H__

#include "net/Pollers/IPoller.h"
#include <vector>
#include <unordered_map>

// 前置声明
struct pollfd;

namespace toym
{
namespace net
{

class Poller: public IPoller {
public:
    Poller();
    ~Poller();

    virtual int poll() override;
    virtual void updateChannel(Channel& channel) override;
    virtual void removeChannel(Channel& channel) override;
    virtual std::vector<Channel*> getActiveChannels(int nActive) override;
private:
    std::vector<struct pollfd> m_pfds;
    std::unordered_map<int, Channel*> channelMap;  // map from fd to channel
};


} // namespace net

} // namespace toym


#endif //__TOYM__NET__POLLERS__POLLER_H__



